package csu.web.mypetstore.web.servlet;

import csu.web.mypetstore.domain.Account;
import csu.web.mypetstore.service.LogService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

public class LogServlet extends HttpServlet {
    private static final String LOG = "/WEB-INF/jsp/account/log.jsp";
    private String username;
    private LogService logService;

    private Account account=new Account();


    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        account = (Account)session.getAttribute("loginAccount");

        username =req.getParameter("username");
        logService = new LogService();
        List<String> logList = logService.getLogInfo(account);
        session.setAttribute("logList",logList);

        req.getRequestDispatcher(LOG).forward(req,resp);
    }
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
